<?php
/**
 * Created by PhpStorm.
 * User: Kevin
 * Date: 2018/2/3
 * Time: 16:29
 */
namespace app\home\controller;
use think\Controller;
use think\Db;
use think\Session;

class LoginController extends CommonController{
    /**
     * showLogin 展示登录页面
     * @return 返回HTML页面
     */
    public function showLogin(){
        return $this->fetch('index/student_login');
    }
    /**
     * userLogin 用户登录账户密码验证
     * @return 返回验证结果
     */
    public function userLogin(){
        $value = input();
        if(!empty($value)){
            extract($value);
           $res = Db::table('ew_student')
               ->where('stu_phone',$phone)
//               ->field('stu_phone,stu_password')
               ->find();
           if($res == ""){
               $resultData['status'] = 0;
               $resultData['msg'] = "手机号输入错误或未注册...";
               return json_encode($resultData);
           }else{
               if(in_array(md5($pwd),$res)){
                   session('studentSession',$res);
                   $resultData['status'] = 1;
                   $resultData['msg'] = "登录成功...";
                   return json_encode($resultData);
               }else{
                   $resultData['status'] = 0;
                   $resultData['msg'] = "密码输入错误...";
                   return json_encode($resultData);
               }
           }
        }
    }



}
